﻿using HomeCloudStorageSystem.Dtos;
using HomeCloudStorageSystem.Models;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using System.Numerics;

namespace HomeCloudStorageSystem.Profiles
{
    public class UserProfile : Profile
    {
        public UserProfile()
        {
            CreateMap<UserForCreationDto, User>()
                .ForMember(
                dist => dist.RegisterDate,
                opt => opt.MapFrom(src => DateTime.Now.ToString("yyyy-MM-dd"))
                )
                .ForMember(
                dist => dist.Permission,
                opt => opt.MapFrom(src => "1111")
                )
                .ForMember(
                dist => dist.State,
                opt => opt.MapFrom(src => 0)
                )
                .ForMember(
                dist => dist.Phone,
                opt => opt.MapFrom(src => src.Phone == "string" ? null : src.Phone)
                ); 
            CreateMap<UserForUpdateDto, User>();
            CreateMap<User, UserForUpdateDto>();
        }
    }
}